package com.bluesky.jwf.component;

import com.bluesky.javawebbrowser.domain.html.tags.Tag;
import com.bluesky.javawebbrowser.domain.html.tags.TagType;
import com.bluesky.jwf.util.JWFServlet;

/**
 * 
 * 
 * @author hz00260
 * 
 */
public class Form extends Component {
	public static String FIELD_WINDOW = "_jwf_window";
	public static String FIELD_WINDOW_WIDTH = "_jwf_window_width";
	public static String FIELD_WINDOW_HEIGHT = "_jwf_window_height";
	public static String FIELD_COMPONENT = "_jwf_component";
	public static String FIELD_EVENT = "_jwf_event";
	public static String FIELD_VIEW_STATE = "_jwf_view_state";

	private Tag script;
	private com.bluesky.javawebbrowser.domain.html.tags.form.Form formTag;
	private Tag windowWidthField;
	private Tag windowHeightField;
	private Tag componentField;
	private Tag eventField;
	private Tag viewStateField;

	@Override
	public void init(String html) {

		super.init(html);

		formTag = (com.bluesky.javawebbrowser.domain.html.tags.form.Form) loadByTagType(TagType.FORM);

		windowWidthField = formTag.loadByAttribute(JWF_ID, FIELD_WINDOW_WIDTH);
		windowHeightField = formTag.loadByAttribute(JWF_ID, FIELD_WINDOW_HEIGHT);

		componentField = formTag.loadByAttribute(JWF_ID, FIELD_COMPONENT);
		eventField = formTag.loadByAttribute(JWF_ID, FIELD_EVENT);
		viewStateField = formTag.loadByAttribute(JWF_ID, FIELD_VIEW_STATE);

		script = loadByJwfId("script");
		script.getParent().removeChild(script);

	}

	@Override
	public Tag getScript() {

		return script;
	}

	public com.bluesky.javawebbrowser.domain.html.tags.form.Form getFormTag() {
		return formTag;
	}

	public void setFormTag(
			com.bluesky.javawebbrowser.domain.html.tags.form.Form formTag) {
		this.formTag = formTag;
	}

	public Tag getComponentField() {
		return componentField;
	}

	public void setComponentField(Tag componentField) {
		this.componentField = componentField;
	}

	public Tag getEventField() {
		return eventField;
	}

	public void setEventField(Tag eventField) {
		this.eventField = eventField;
	}

	public void setScript(Tag script) {
		this.script = script;
	}

	public Tag getViewStateField() {
		return viewStateField;
	}

	public void setViewStateField(Tag viewStateField) {
		this.viewStateField = viewStateField;
	}

}
